package com.atguigu.contriller;

import com.atguigu.entity.User;
import com.atguigu.resp.ResultData;
import com.atguigu.service.UserService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("/{id}")
    public ResultData<User> getUserById(@PathVariable Serializable id) {
        return  ResultData.success(userService.getById(id));
    }

    @PostMapping("/add")
    public ResultData<Boolean> addUser(@RequestBody User user) {
        return ResultData.success(userService.save(user));
    }
}
